#include <string.h>
#include <iostream>

using namespace std;

int main()
{
    // allocate 3 bytes on the stack
    char tmp[3];

    // don't think you write 3 bytes into the 3-bytes array. C strings
    // have a "hidden" 0-byte at the end, so we are writing 4 bytes -
    // thus overwriting 1 byte on the stack which comes right after
    // the memory that has been dedicated to the array.

    // while this is not an exploit actually, one can think of writing
    // a user-specified string there. a malicious user could then
    // insert just about anything onto your stack and wreak severe
    // havoc on the program's control flow.

    strcpy(tmp, "123");
    cout << tmp << endl;

    return 0;
}
